<template>
    <van-nav-bar title="物流详情" left-text="" left-arrow @click-left="goBack" />
    <section class="aui-flexView">
        <!-- 订单详细 -->
        <section class="aui-scrollView">
            <!-- 订单状态 -->
            <div class="aui-pay-change">
                <div class="aui-flex">
                    <div class="aui-flex-box">
                        <h3>{{ detail.status_text }}</h3>
                    </div>
                    <div class="aui-pay-zfb">
                        <img src="/assets/images/icon-zfb.png" alt="" />
                    </div>
                </div>
            </div>

            <!-- 收货地址 -->
            <div class="aui-flex">
                <div class="aui-flex-add">
                    <img :src="LoginUser.avatar" alt="" />
                </div>
                <div class="aui-flex-box">
                    <h3>
                        {{ detail.consignee }} <em> {{ detail.mobile }}</em>
                    </h3>
                    <p>{{ detail.region_text }}</p>
                </div>
            </div>
            <!-- 物流信息 -->
            <van-steps direction="vertical" :active="0">
                <van-step v-for="(item,index) in  expresslist" :key="index">
                    <h3>{{ item.status }}</h3>
                    <p>{{ item.time }}</p>
                </van-step>
            </van-steps>
        </section>
    </section>
</template>
<script setup>
const router = useRouter();
const route = useRoute();
const goBack = () => {
    router.push('/business/order/index')
}
const orderid = ref(route.query.orderid ?? 0)
const detail = ref({})
const expresslist = ref([])
const { cookies } = useCookies();
const LoginUser = reactive(cookies.get("LoginUser") ?? {});
onBeforeMount(() => {
    getInfoData()
    getExpressData()
})
const getInfoData = async () => {
    let result = await Api.orderInfo({
        busid: LoginUser.id,
        orderid: orderid.value
    });
    if (result.code == 1) {
        detail.value = result.data
    }
}
const getExpressData = async () => {
    let result = await Api.orderExpress({
        busid: LoginUser.id,
        orderid: orderid.value
    });
    if (result.code == 1) {
        console.log(result)
        expresslist.value = result.data.data
    }
}

</script>
<style>
@import url('/assets/css/info.css');
</style>